//
//  AppDelegate_Pad.m
//  WebPDA
//
//  Created by Justin Yip on 10-7-21.
//  Copyright __MyCompanyName__ 2010. All rights reserved.
//

#import "AppDelegate_Pad.h"


@implementation AppDelegate_Pad
#define DEBUG_COVER_DB
#pragma mark -
#pragma mark Application delegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {    
	
    // Override point for customization after application launch
	NSLog(@"launch in ipad");
	
#ifdef DEBUG_COVER_DB
	/*
	 将测试数据库（与应用一起打包）覆盖应用数据库
	 */
	//应用数据库路径
	NSString *testDBPath = [[NSBundle mainBundle] pathForResource:@"WebPDA" ofType:@"sqlite"];
	//测试数据库路径
	NSString *appDBPath = [[self applicationDocumentsDirectory] stringByAppendingPathComponent:@"WebPDA.sqlite"];
	
	NSError *error;
	BOOL op_result = NO;
	NSFileManager *fileManager = [NSFileManager defaultManager];
	//删除默认数据库
	op_result = [fileManager removeItemAtPath:appDBPath error:&error];
	NSLog(@"delete application db %@", op_result ? @"success" : @"fail");
	//复制测试数据库到应用数据库
	op_result = [fileManager copyItemAtPath:testDBPath toPath:appDBPath error:&error];
	NSLog(@"cover app db with test db %@", op_result ? @"success" : @"fail");
#endif
	
	//loginViewCtrl = [[LoginViewController alloc] init];
	
    [window makeKeyAndVisible];
	
	return YES;
}


/**
 Superclass implementation saves changes in the application's managed object context before the application terminates.
 */
- (void)applicationWillTerminate:(UIApplication *)application {
	[super applicationWillTerminate:application];
}


#pragma mark -
#pragma mark Memory management

- (void)dealloc {
	//[loginViewCtrl release];
	[super dealloc];
}


@end

